import java.util.*;

class Student {

}
public class Test {

    public static void main(String[] args) {
        Set<String> set=new TreeSet<>();
        set.add("abc");
        set.add("def");
        set.add("abc");
//        System.out.println(set);
        //用迭代器输出
        Iterator<String> it=set.iterator();
        while(it.hasNext()) {
            System.out.println(it.next());
        }
    }

    public static void main1(String[] args) {
        Map<Student,String> map=new TreeMap<>();//TreeMap就是一颗二叉搜索树
        map.put(new Student(),"zhangsan");


        /*map.put("及时雨","宋江");
        map.put("及时雨","宋江2");//set中只有两个值，及时雨和齐天大圣，且值为宋江2，覆盖后的结果
        map.put("齐天大圣","顺悟空");

        //set只能输出key，如何将key和val组合到一起？用entrySet，返回值是<Map.Entry<K,V>>
        Set<Map.Entry<String,String>> entries=map.entrySet();
        for(Map.Entry<String,String> entry:entries){
//            System.out.println(entry);
            System.out.println("key:"+entry.getKey()+",val:"+entry.getValue());
        }



        Set<String> set=map.keySet();
        System.out.println(set);


       String val=map.get("及时雨");
        System.out.println(val);

        String val2=map.getOrDefault("及时雨2","haha");//key不存在时，输出默认值
        System.out.println(val2);

        //删除key对应的映射关系
        String val3=map.remove("及时雨");
        System.out.println(val3);*/




    }
}
